import React from 'react';

export default class Fb extends React.Component {
  static defaultProps = {
    a: 0,
    b: 1,
  };

  state = {
    list: [this.props.a, this.props.b],
  };

  componentDidMount() {
    this.statetimer = setInterval(() => {
      const [a, b] = this.state.list.slice(-2);
      this.setState({ list: [...this.state.list, a + b] });
    }, 1000);
  }
  componentWillUnmount(){
    console.log('componentWillUnmount'+this.timer)
    clearInterval(this.timer);
  }

  render() {
    const { list, times } = this.state;
    return (
      <>
        {list.join(', ')} {times}
      </>
    );
  }
}
